/*
 * =====================================================================================
 *
 *       Filename:  3664partion.c
 *
 *    Description:  use qsort split to find the top k
 *
 *        Version:  1.0
 *        Created:  2012年06月28日 17时00分04秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Regan (), lcqhigh@gmail.com
 *        Company:  
 *
 * =====================================================================================
 */

#include	<stdio.h>
#include	<stdlib.h>
#include	<math.h>

static int v1[50001];
static int v2[50001];
static int *ptrs[50001];

int expectedk = 0;

void swap(int **pp1, int **pp2)
{
    int *tempPtr = *pp1;
    *pp1 = *pp2;
    *pp2 = tempPtr;
}

int partition(int **x, int n)
{
    int pivot = 0;
    int mid = abs(rand()) % n;
    if (n > 2) {
        --n;
        if (mid < 1 || mid > n-1)
            mid = 1;
        if (*x[0] > *x[mid]) swap(&x[0], &x[mid]);
        if (*x[0] > *x[n])   swap(&x[0], &x[n]);
        if (*x[mid] > *x[n]) swap(&x[mid], &x[n]);

        swap(&x[mid], &x[n-1]);
        int l = 0, h = n - 1;
        for (;;) {
            while (*x[++l] < *x[n-1]);
            while (*x[--h] > *x[n-1]);
            if (l >= h)
                break;
            swap(&x[l], &x[h]);
        }
        swap(&x[l], &x[n-1]);
        pivot = l;
    } else if (n == 2 && *x[0] > *x[1]) {
        swap(&x[0], &x[1]);
        pivot = 0;
    }
    return pivot+1;
}

void findKmax(int *pArr[], int n)
{
    if (n == 0 || n == expectedk)
        return;
    
    int sp = partition(pArr, n);
    if ((n - sp) <= expectedk)
    {
        expectedk -= (n - sp);
        if (expectedk > 0)
            findKmax(pArr, sp);
    } else {
        findKmax(pArr+sp, n-sp);
    }
    return;
}

int main(int argc, char *argv[])
{
    int n, k;
    int i, winidx = 0;
    while (scanf("%d %d", &n, &k) == 2) {
        for (i = 0; i < n; ++i)
        {
          scanf("%d %d", &v1[i], &v2[i]);
          //ignore this is wrong
          ptrs[i] = &v1[i];
        }

        expectedk = k;
        findKmax(ptrs, n);

        winidx = n-k;
        for (i = n-k+1; i < n; ++i)
        {
            if (v2[(ptrs[i]-v1)] > v2[(ptrs[winidx]-v1)])
                winidx = i;
        }
        printf ( "%lu\n",(ptrs[winidx]-v1)+1);
    }
    return 0;
}
